//
//  MyTabBarController.swift
//  NavTabTest
//
//  Created by Damon on 16/7/1.
//  Copyright © 2016年 zhangle.in.zmj. All rights reserved.
//

import UIKit

class MyTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }
    
//    override var selectedIndex: Int {
//        willSet {
//            print("Will SelectedIndex = \(newValue)")
//            let vc = self.viewControllers![newValue]
//            self.title = vc.title
//        }
//        
//        didSet {
//            print("Did SelectedIndex = \(oldValue)")
//        }
//    }
    
    //点击UITabBarItem时才会调用该方法,或者UITabBarControllerDelegate中的
    //    public func tabBarController(tabBarController: UITabBarController, shouldSelectViewController viewController: UIViewController) -> Bool
    //  当有侧滑栏就需要另外设置TabBarController中navgationItem中的控件
    //  TabBarController带有导航条,这样UITabBar就能够被隐藏掉
    //  另外这里有离屏渲染
    override func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem) {
        let vc = self.viewControllers![item.tag]
        self.title = vc.title
    }

//    override unowned(unsafe) var selectedViewController: UIViewController? {
//        willSet {
//            
//        }
//        
//        didSet {
//            
//        }
//    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
